import { defineComponent, resolveComponent, openBlock, createElementBlock, createVNode, mergeProps, withCtx, Fragment, renderList, createBlock, renderSlot, createCommentVNode, toDisplayString } from "vue";
function toInteger(dirtyNumber) {
  if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
    return NaN;
  }
  var number = Number(dirtyNumber);
  if (isNaN(number)) {
    return number;
  }
  return number < 0 ? Math.ceil(number) : Math.floor(number);
}
function requiredArgs(required, args) {
  if (args.length < required) {
    throw new TypeError(required + " argument" + (required > 1 ? "s" : "") + " required, but only " + args.length + " present");
  }
}
function _typeof$1(obj) {
  "@babel/helpers - typeof";
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    _typeof$1 = function _typeof2(obj2) {
      return typeof obj2;
    };
  } else {
    _typeof$1 = function _typeof2(obj2) {
      return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
    };
  }
  return _typeof$1(obj);
}
function toDate(argument) {
  requiredArgs(1, arguments);
  var argStr = Object.prototype.toString.call(argument);
  if (argument instanceof Date || _typeof$1(argument) === "object" && argStr === "[object Date]") {
    return new Date(argument.getTime());
  } else if (typeof argument === "number" || argStr === "[object Number]") {
    return new Date(argument);
  } else {
    if ((typeof argument === "string" || argStr === "[object String]") && typeof console !== "undefined") {
      console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
      console.warn(new Error().stack);
    }
    return new Date(NaN);
  }
}
function addMilliseconds(dirtyDate, dirtyAmount) {
  requiredArgs(2, arguments);
  var timestamp = toDate(dirtyDate).getTime();
  var amount = toInteger(dirtyAmount);
  return new Date(timestamp + amount);
}
function getTimezoneOffsetInMilliseconds(date) {
  var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
  utcDate.setUTCFullYear(date.getFullYear());
  return date.getTime() - utcDate.getTime();
}
function _typeof(obj) {
  "@babel/helpers - typeof";
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    _typeof = function _typeof2(obj2) {
      return typeof obj2;
    };
  } else {
    _typeof = function _typeof2(obj2) {
      return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
    };
  }
  return _typeof(obj);
}
function isDate(value) {
  requiredArgs(1, arguments);
  return value instanceof Date || _typeof(value) === "object" && Object.prototype.toString.call(value) === "[object Date]";
}
function isValid(dirtyDate) {
  requiredArgs(1, arguments);
  if (!isDate(dirtyDate) && typeof dirtyDate !== "number") {
    return false;
  }
  var date = toDate(dirtyDate);
  return !isNaN(Number(date));
}
function subMilliseconds(dirtyDate, dirtyAmount) {
  requiredArgs(2, arguments);
  var amount = toInteger(dirtyAmount);
  return addMilliseconds(dirtyDate, -amount);
}
function addLeadingZeros(number, targetLength) {
  var sign = number < 0 ? "-" : "";
  var output = Math.abs(number).toString();
  while (output.length < targetLength) {
    output = "0" + output;
  }
  return sign + output;
}
var formatters = {
  y: function y(date, token) {
    var signedYear = date.getUTCFullYear();
    var year = signedYear > 0 ? signedYear : 1 - signedYear;
    return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
  },
  M: function M(date, token) {
    var month = date.getUTCMonth();
    return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
  },
  d: function d(date, token) {
    return addLeadingZeros(date.getUTCDate(), token.length);
  },
  a: function a(date, token) {
    var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? "pm" : "am";
    switch (token) {
      case "a":
      case "aa":
        return dayPeriodEnumValue.toUpperCase();
      case "aaa":
        return dayPeriodEnumValue;
      case "aaaaa":
        return dayPeriodEnumValue[0];
      case "aaaa":
      default:
        return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
    }
  },
  h: function h(date, token) {
    return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
  },
  H: function H(date, token) {
    return addLeadingZeros(date.getUTCHours(), token.length);
  },
  m: function m(date, token) {
    return addLeadingZeros(date.getUTCMinutes(), token.length);
  },
  s: function s(date, token) {
    return addLeadingZeros(date.getUTCSeconds(), token.length);
  },
  S: function S(date, token) {
    var numberOfDigits = token.length;
    var milliseconds = date.getUTCMilliseconds();
    var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
    return addLeadingZeros(fractionalSeconds, token.length);
  }
};
var formatters$1 = formatters;
var formattingTokensRegExp = /(\w)\1*|''|'(''|[^'])+('|$)|./g;
var escapedStringRegExp = /^'([^]*?)'?$/;
var doubleQuoteRegExp = /''/g;
var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
function lightFormat(dirtyDate, formatStr) {
  requiredArgs(2, arguments);
  var originalDate = toDate(dirtyDate);
  if (!isValid(originalDate)) {
    throw new RangeError("Invalid time value");
  }
  var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
  var utcDate = subMilliseconds(originalDate, timezoneOffset);
  var tokens = formatStr.match(formattingTokensRegExp);
  if (!tokens)
    return "";
  var result = tokens.map(function(substring) {
    if (substring === "''") {
      return "'";
    }
    var firstCharacter = substring[0];
    if (firstCharacter === "'") {
      return cleanEscapedString(substring);
    }
    var formatter = formatters$1[firstCharacter];
    if (formatter) {
      return formatter(utcDate, substring);
    }
    if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
      throw new RangeError("Format string contains an unescaped latin alphabet character `" + firstCharacter + "`");
    }
    return substring;
  }).join("");
  return result;
}
function cleanEscapedString(input) {
  var matches = input.match(escapedStringRegExp);
  if (!matches) {
    return input;
  }
  return matches[1].replace(doubleQuoteRegExp, "'");
}
const _hoisted_1 = { class: "data-table" };
const _hoisted_2 = { key: 0 };
const _hoisted_3 = { key: 1 };
const __default__ = { name: "XcTableV3" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    columns: {
      type: [],
      default: () => []
    }
  },
  setup(__props) {
    const formatDate = (value, d2 = "yyyy-MM-dd HH:mm:ss") => {
      return value == null || value === "" ? "-" : lightFormat(typeof value === "string" ? new Date(value) : value, d2);
    };
    return (_ctx, _cache) => {
      const _component_el_table_column = resolveComponent("el-table-column");
      const _component_el_table = resolveComponent("el-table");
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(_component_el_table, mergeProps(_ctx.$attrs, {
          style: { "width": "100%" },
          "empty-text": "\u6682\u65E0\u6570\u636E"
        }), {
          default: withCtx(() => [
            (openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (item, index2) => {
              return openBlock(), createElementBlock(Fragment, { key: index2 }, [
                item.slot ? (openBlock(), createBlock(_component_el_table_column, {
                  key: 0,
                  label: item.label,
                  fixed: item.fixed || false,
                  align: item.align || "left",
                  width: item.width || ""
                }, {
                  default: withCtx((scope) => [
                    renderSlot(_ctx.$slots, item.slot, { scope })
                  ]),
                  _: 2
                }, 1032, ["label", "fixed", "align", "width"])) : createCommentVNode("", true),
                !item.slot && item.type == "selection" ? (openBlock(), createBlock(_component_el_table_column, {
                  key: 1,
                  type: "selection"
                })) : createCommentVNode("", true),
                !item.slot && item.type == "index" ? (openBlock(), createBlock(_component_el_table_column, {
                  key: 2,
                  type: "index",
                  label: "\u5E8F\u53F7"
                })) : createCommentVNode("", true),
                !item.slot && !item.type ? (openBlock(), createBlock(_component_el_table_column, {
                  key: 3,
                  prop: item.prop,
                  label: item.label,
                  fixed: item.fixed || false,
                  align: item.align || "left",
                  width: item.width || "",
                  sortable: item.sortable || false,
                  "show-overflow-tooltip": item.tooltip
                }, {
                  default: withCtx((scope) => [
                    item.formatDate ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(formatDate(scope.row[item.prop], item.formatDate)) + toDisplayString(item.unit), 1)) : (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(scope.row[item.prop]) + toDisplayString(item.unit), 1))
                  ]),
                  _: 2
                }, 1032, ["prop", "label", "fixed", "align", "width", "sortable", "show-overflow-tooltip"])) : createCommentVNode("", true)
              ], 64);
            }), 128))
          ]),
          _: 3
        }, 16)
      ]);
    };
  }
});
console.log(_sfc_main.name);
_sfc_main.install = (Vue) => {
  Vue.component(_sfc_main.name, _sfc_main);
};
const components = [_sfc_main];
const install = (App) => {
  components.forEach((item) => {
    console.log(App, "App", item.name);
    App.component(item.name, item);
  });
};
var index = {
  install
};
export { _sfc_main as XcTableV3, index as default };
